package com.upup.cloud.chhk_gj;

import com.upup.cloud.chhk_gj.service.ReptileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Sink;


@Slf4j
@EnableBinding(Sink.class)
@SpringBootApplication
public class ChhkGjApplication implements CommandLineRunner {

	@Autowired
	ReptileService reptileService;

	public static void main(String[] args) {
		new SpringApplicationBuilder(ChhkGjApplication.class)
				.web(WebApplicationType.NONE)
				.run(args);
	}

	@Override
	public void run(String... args) throws Exception {
		for (int i = 0; i < 200; i++) {
			new Thread("爬虫线程"+i) {
				@Override
				public void run() {
					while (true) {
						try {
							//春秋国际爬虫
							reptileService.getFlight();
						}catch (Exception e){
							log.info("抓取失败");
						}
					}
				}
			}.start();
		}
	}
}

